/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */

package vehicle.bol;

import java.sql.ResultSet;
import java.util.ArrayList;
import vehicle.dal.DAL;
import vehicle.entity.Customer;

/**
 *
 * @author lab1
 */
public class CustomerBOL {
    public static Customer checkLogin(String account, String password) {
        DAL dal = new DAL();
        try {
            ArrayList paramlist = new ArrayList();
            paramlist.add(account);
            paramlist.add(password);
            ResultSet rs = dal.executeQuery("loginCustomer", paramlist);
            if (rs.next()) {
                Customer a = new Customer();
                a.setCustomerName(rs.getString("CustomerName"));
                a.setCusFullName(rs.getString("CusFullName"));
                a.setCusPassword(rs.getString("CusPassword"));
                a.setAddress(rs.getString("ADDRESS"));
                a.setDateOfBirth(rs.getDate("DateOfBirth"));
                a.setGender(rs.getBoolean("Gender"));
                a.setEmail(rs.getString("Email"));
                a.setPhoneNumber(rs.getString("PhoneNumber"));
                a.setStatus(rs.getBoolean("STATUS"));
                return a;
            }
        } catch (Exception ex) {
            
        } finally {
            dal.closeConnection();
        }
        return null;
    }

}
